package com.mrx.xfriendship.telnet.server;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author Mr.X
 * @since 2023-02-19 09:22
 */
@Component
@ConditionalOnExpression("${telnet}")
public class TelnetServerListener {

    private static final Logger logger = LoggerFactory.getLogger(TelnetServerListener.class);

    @EventListener(ApplicationReadyEvent.class)
    public void startServer() throws Exception {
        logger.debug("SpringBoot 启动完毕, 准备启动 Telnet 服务器");
        new TelnetServer().startServer();
    }

}
